package com.code.rocketmqproducer.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lyf
 * @date 2021-12-19 11:31
 */
@Slf4j
@Configuration
public class MQProducerConfig {

    @Bean
    public DefaultMQProducer mqProducer() throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer("myGroupGid");
        producer.setNamesrvAddr("127.0.0.1:9876");
        producer.start();
        log.info("rocketmq producer start success...");
        return producer;
    }
}
